/*
 * @Author: yangzonglong
 * @Date: 2021-07-09 13:24:11
 * @version: v1.0.0
 * @Descripttion: 设置默认值
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2021-08-05 09:05:06
 * @Auditor:
 */
import React, { useCallback } from 'react';
import { Form, Input } from 'antd';

const FormItem = Form.Item;

interface IProps {
  value?: string;
  textArea?: boolean;
  onChange(value: string): void;
}

const InitialValue = ({ value, onChange, textArea }: IProps) => {
  const _onChange = useCallback(
    (e: React.BaseSyntheticEvent) => {
      onChange(e.target.value);
    },
    [onChange]
  );

  // return null;
  return (
    <FormItem label='默认内容' tooltip='设置默认内容后，默认值会显示在该模块的输入框中，填写者若不做修改，默认值将会作为填写者的数据提交'>
      {textArea ? <Input.TextArea onChange={_onChange} value={value} /> : <Input onChange={_onChange} value={value} />}
    </FormItem>
  );
};

export default InitialValue;
